// 引入基类
const Generator = require('yeoman-generator')

// 导出一个类
module.exports = class extends Generator {
  prompting() {
    return this.prompt([
      {
        type: 'input',
        name: 'name',
        message: '请输入项目名称: ',
        default: this.appname
      },
      {
        type: 'input',
        name: 'username',
        message: '你的姓名: ',
        default: 'haha'
      }
    ])
    .then(answers => {
      this.answers = answers
    })
  }

  writing () {
    let srcDir = this.sourceRoot()
    let destDir = this.destinationRoot()

    this.fs.copyTpl(srcDir, destDir,this.answers)


    // this.addDependencies({
    //   "axios": "^0.27.2",
    //   "core-js": "^3.6.5",
    //   "fs-extra": "^10.1.0",
    //   "qs": "^6.10.3",
    // })
    
  }

  install () {
    this.env.options.nodePackageManager = 'npm'
  }

  end () {
    this.log('创建成功!')
  }
}